home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / FROMUTS / UNIXLIB37B / test / c / allocatst2 < prev    next >
Text File  |  1992-02-17  |  723b  |  53 lines

  1. #include <stdlib.h>
  2. #include <time.h>
  3. #include <stdio.h>
  4. #include <setjmp.h>
  5.  
  6. #include "alloca.h"
  7.  
  8. #define ASIZE 2048
  9. #define ACNT  64
  10.  
  11. static int acnt,ajmp;
  12.  
  13. static jmp_buf ajmb;
  14.  
  15. static void allocatst(void)
  16. {
  17. int *b;
  18. register int i;
  19.  
  20. srand(time(0));
  21.  
  22. b = alloca(ASIZE);
  23.  
  24. for (i = 0; i < (ASIZE>>2); i++) b[i] = rand();
  25.  
  26. printf("%x\t",b);
  27.  
  28. b = alloca(ASIZE);
  29.  
  30. for (i = 0; i < (ASIZE>>2); i++) b[i] = rand();
  31.  
  32. printf("%x\n",b);
  33.  
  34. if (++acnt == ACNT) { if (ajmp) longjmp(ajmb,-1); else return; }
  35.  
  36. allocatst();
  37. }
  38.  
  39. int main()
  40. {
  41. acnt = 0,ajmp = 0; allocatst();
  42.  
  43. if (setjmp(ajmb)) goto next;
  44.  
  45. acnt = 0,ajmp = -1; allocatst();
  46.  
  47. next: acnt = 0,ajmp = 0; allocatst();
  48.  
  49. if (setjmp(ajmb)) exit(0);
  50.  
  51. acnt = 0,ajmp = -1; allocatst();
  52. }
  53.